package com.example.doctor.jpa;

import com.example.common.entity.Template;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import javax.transaction.Transactional;
import java.util.List;

public interface TemplateRepository extends JpaRepository<Template,Long> {

    @Query(value = "SELECT * FROM z_drug_template WHERE dcid_bigint =:dcId",nativeQuery = true)
    List<Template> findByDCid(@Param("dcId") Long dcId);

    @Transactional
    @Modifying
    @Query(value = "DELETE FROM z_drug_template WHERE tid_bigint =:tid",nativeQuery = true)
    void deleteBytId(@Param("tid") Long tid);
}
